import Vue from 'vue'
import Router from 'vue-router'
import Home from '../views/Home.vue'
import Login from '../views/Login.vue'
import Profile from '../views/Profile.vue'
import BasicInfo from '../views/ProfileChildren/BasicInfo.vue'
import Account from '../views/ProfileChildren/Account.vue'
import MyMoment from '../views/ProfileChildren/MyMoment.vue'
import Achievement from '../views/ProfileChildren/Achievement'
import Discuss from '../views/Discuss.vue'
import Edit from '../views/Edit.vue'
import OtherProfile from '../views/OtherProfile.vue'
import Detail from '../views/Detail.vue'
import Job from '../views/Job.vue'
import Chat from '../views/Chat.vue'
import ErrorComponent from '../components/ErrorComponent.vue'
import ProfileHome from '../views/ProfileChildren/Home.vue'
import AvatarProfileCard from '../components/AvatarProfileCard'
import Focus from '../views/ProfileChildren/Focus'
import Resume from '../views/Resume'
import SubmitJob from '../views/SubmitJob'
import SubmitCompany from '../views/SubmitCompany'
import JobDetail from '../views/JobDetail'
import Company from '../views/Company'
import MySubmitJob from '../views/MySubmitJob'
Vue.use(Router)
const originalPush = Router.prototype.push
Router.prototype.push = function push (location) {
  return originalPush.call(this, location).catch(err => err)
}
export default new Router({
  routes: [
    {
      path: '/profilecard',
      component: AvatarProfileCard
    },
    {
      path: '/',
      redirect: '/login'
    },
    {
      path: '/home',
      name: 'Home',
      component: Home
    },
    {
      path: '/login',
      name: 'Login',
      component: Login
    },
    {
      path: '/profile',
      name: 'Profile',
      redirect: '/profile/home',
      component: Profile,
      children: [
        {
          path: '/profile/basicinfo',
          component: BasicInfo,
          name: 'BasicInfo'
        },
        {
          path: '/profile/account',
          component: Account,
          name: 'Account'
        }, {
          path: '/profile/mymoment',
          component: MyMoment,
          name: 'mymoment'
        }, {
          path: '/achievement',
          component: Achievement,
          name: 'achievement'
        }, {
          path: '/profile/home',
          component: ProfileHome
        }, {
          path: '/profile/focus',
          component: Focus
        }
      ]
    },
    {
      path: '/submitJob',
      component: SubmitJob
    },
    {
      path: '/submitCompany',
      component: SubmitCompany
    },
    {
      path: '/company/:companyId',
      component: Company
    },
    {
      path: '/resume',
      name: 'Resume',
      component: Resume
    },
    {
      path: '/discuss',
      name: 'Discuss',
      component: Discuss
    },
    {
      path: '/edit',
      name: 'Edit',
      component: Edit
    },
    {
      path: '/profile/:userId',
      name: 'OtherProfile',
      component: OtherProfile
    },
    {
      path: '/detail/:momentId',
      name: 'Detail',
      component: Detail
    },
    {
      path: '/job',
      name: 'Job',
      component: Job
    },
    {
      path: '/mySubmitJob',
      component: MySubmitJob
    },
    {
      path: '/chat',
      name: 'chat',
      component: Chat
    },
    {
      path: '/job/detail/:jobId',
      component: JobDetail
    },
    {
      path: '*',
      name: 'error',
      component: ErrorComponent
    }
  ],
  mode: 'history',
  scrollBehavior (to, from, savedPosition) {
    return { x: 0, y: 0 }
  }
})
